package systemServer.members;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import payment.IPaymentMethod;
import payment.PaymentMethodFactory;
import systemServer.reproduction.Play;
import systemServer.reproduction.Song;
import dao.MemberDAO;
import dto.MemberDTO;
import dto.MemberPayDTO;

@PersistenceCapable
public class Member { 
	@PrimaryKey
	private String userName;
	private String password;
	private int points;
	private IPaymentCalculation calculation;
	private IPaymentMethod payment;
	private String calculationString;
	private String paymentString;
	
	public Member(String username, String password, String sCalculation, String payment) {
		super();
		this.userName = username;
		this.password = password;
		this.points = 0;
		this.calculation = PaymentCalculationFactory.create(sCalculation);
//		this.payment = PaymentMethodFactory.create(payment);
		this.paymentString = payment;
		this.calculationString = sCalculation;
		
	}
	
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getPoints() {
		return points;
	}

	private void setPoints(int points) { //private 'cause in first instance any external method will use it, is for in-class purpouses only
		this.points = points;
	}

	public String getUsername() {
		return userName;
	}

	public List<Song> showFavourite() {
		return null;
	}
	
	public List<Recomendation> showRecomendations() {
		return null;
	}
	
	public void addFavourite(Song song) {
	}
	
	public double calculate() {
		return calculation.calculate();
	}
	
	public void addPermanent(Song song) {
	}
	
	public void recomend (Song song, Member targetMember) {
	}
	
	public void changeMemberType(IPaymentCalculation memberType) {
	}
	
	public void changePaymentMethod(IPaymentMethod paymentMethod) {
	}
	
	public List<Song> showPermanent() {
		return null;
	}
	
	public void pay(MemberPayDTO mpd) {
		calculate();
		//TODO hay que hacer server to server communication
	}
	
//	public List<Play> getPlays() {
//		return MemberDAO.getInstance().getMemberPlays(this);
//	}
	
//	public void addPlay(Play play) {
//		plays.add(play);
//
//	}

	@Override
	public String toString() {
		return "Member [userName=" + userName + ", password=" + password
				+ ", points=" + points + ", calculation="
				+ calculation + ", payment=" + payment + "]";
	}

	public String getCalculationString() {
		return calculationString;
	}

	public void setCalculationString(String calculationString) {
		this.calculationString = calculationString;
	}

	public String getPaymentString() {
		return paymentString;
	}

	public void setPaymentString(String paymentString) {
		this.paymentString = paymentString;
	}
}
	   
